using System;
using Prism.Events;
namespace DTS.Common.Events
{
///
/// The ShowStatus event.
///
///
/// This event is used by the services to display the current status.
///
public class ShowStatus : PubSubEvent
{
}
///
/// The StatusInfo is used by ShowStatus event to display the current status.
///
public class StatusInfo
{
///
/// the current state of a process
///
public enum StatusState
{
Idle, //Ready state, no longer doing anything
Busy, //busy, currently doing something
DoneNoError, //no longer working, done, no errors
DoneFailed //no longer working, did not complete process
}
public StatusState CurrentState
{
get;
private set;
}
///
/// Gets or sets a value indicating whether this object is busy.
///
public bool IsBusy => CurrentState == StatusState.Busy;
///
/// Gets or sets the IsOk flag.
///
public bool IsOk
{
get;
set;
}
///
/// Gets or sets the progress bar percentage.
///
public decimal Percentage
{
get;
set;
}
///
/// Gets or sets the status information.
///
public string Text
{
get;
set;
}
///
/// Gets or sets the id of the process.
///
public int ProcessId
{
get;
set;
}
///
/// creates a new status info, sets the text to the default for the state
/// note that consumers are free not to use the Text Property of the Status Info,
/// but we set it anyhow.
///
///
///
///
///
///
public StatusInfo(StatusState state, string text = null, decimal percentage = -1, int processId = -1, bool isOk = true)
{
CurrentState = state;
IsOk = isOk;
Percentage = percentage;
Text = text;
ProcessId = processId;
if (null == text)
{
Text = Strings.Strings.ResourceManager.GetString("StatusState_" + state) ?? state.ToString();
}
}
public void Unsubscribe(ShowStatus showStatus)
{
Text = String.Empty;
CurrentState = StatusState.Idle;
}
}
}