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 { public IStatusAndProgressFooterView View { get; set; } public IBaseViewModel Parent { get; set; } private IEventAggregator _eventAggregator { get; set; } private IUnityContainer _unityContainer { get; set; } public InteractionRequest NotificationRequest { get; private set; } public new InteractionRequest ConfirmationRequest { get; private set; } /// /// Creates a new instance of the FilterViewModel. /// /// The StatusAndProgressBar View interface. /// The logical placeholder defined within the application's UI (in the shell or within views) into which views are displayed. /// The EventAggregator which allows different components to publish/subscribe to events without being coupled to each other. /// The Unity container. public StatusAndProgressFooterViewModel(IStatusAndProgressFooterView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer) : base(regionManager, eventAggregator, unityContainer) { View = view; View.DataContext = this; NotificationRequest = new InteractionRequest(); ConfirmationRequest = new InteractionRequest(); _eventAggregator = eventAggregator; _unityContainer = unityContainer; _eventAggregator.GetEvent().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; /// ///Occurs when a property value changes. /// 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 } }