Files
DP44/DataPRO/Modules/StatusAndProgressBar/.svn/pristine/89/8948f069a06c385072ccb3435c1ce02c8475fc1c.svn-base
2026-04-17 14:55:32 -04:00

105 lines
4.0 KiB
Plaintext

using System;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Windows;
using DTS.Common.Base;
using DTS.Common.Events;
using DTS.Common.Interactivity;
using DTS.Common.Interface;
using Prism.Events;
using Prism.Regions;
using Unity;
namespace DTS.StatusAndProgressBar
{
public class StatusAndProgressFooterViewModel : BaseViewModel<IStatusAndProgressBarFooterViewModel>, IStatusAndProgressBarFooterViewModel
{
public IStatusAndProgressFooterView View { get; set; }
public IBaseViewModel Parent { get; set; }
private IEventAggregator _eventAggregator { get; set; }
private IUnityContainer _unityContainer { get; set; }
public InteractionRequest<Notification> NotificationRequest { get; private set; }
public new InteractionRequest<Confirmation> ConfirmationRequest { get; private set; }
/// <summary>
/// Creates a new instance of the FilterViewModel.
/// </summary>
/// <param name="view">The StatusAndProgressBar View interface.</param>
/// <param name="regionManager">The logical placeholder defined within the application's UI (in the shell or within views) into which views are displayed.</param>
/// <param name="eventAggregator">The EventAggregator which allows different components to publish/subscribe to events without being coupled to each other.</param>
/// <param name="unityContainer">The Unity container.</param>
public StatusAndProgressFooterViewModel(IStatusAndProgressFooterView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)
: base(regionManager, eventAggregator, unityContainer)
{
View = view;
View.DataContext = this;
NotificationRequest = new InteractionRequest<Notification>();
ConfirmationRequest = new InteractionRequest<Confirmation>();
_eventAggregator = eventAggregator;
_unityContainer = unityContainer;
_eventAggregator.GetEvent<ProgressBarEvent>().Subscribe(OnStatusAndProgressBarEvent);
}
#region Properties
public new bool IsMenuIncluded { get; set; }
public new bool IsNavigationIncluded { get; set; }
public new bool IsBusy { get; set; }
public new bool IsDirty { get; }
public new event PropertyChangedEventHandler PropertyChanged;
///<summary>
///Occurs when a property value changes.
///</summary>
private new void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public string ProgressText { get; set; }
public Visibility ProgressBarVisiblity { get; set; }
public int ProgressBarValue { get; set; }
#endregion Properties
#region Methods
private void SetProgressText(string value)
{
ProgressText = value;
OnPropertyChanged("ProgressText");
}
private void SetProgressBarVisibility(Visibility visibility)
{
ProgressBarVisiblity = visibility;
OnPropertyChanged("ProgressBarVisibility");
}
private void SetProgressBarValue(int value)
{
ProgressBarValue = value;
OnPropertyChanged("ProgressBarValue");
}
private void OnStatusAndProgressBarEvent(ProgressBarEventArg args)
{
if (args.ProgressBarName != "Footer") { return; }
if (args.SetPercentage)
{
SetProgressBarValue(Convert.ToInt32(args.ProgressBarPercentage));
}
if (args.SetText)
{
SetProgressText(args.ProgressBarText);
}
if (args.SetVisibility)
{
SetProgressBarVisibility(args.ProgressBarVisibility);
}
}
#endregion Methods
}
}