Files
DP44/Common/DTS.CommonCore/Events/ShowStatus.cs
2026-04-17 14:55:32 -04:00

108 lines
3.1 KiB
C#

using System;
using Microsoft.Practices.Prism.Events;
namespace DTS.Common.Events
{
/// <summary>
/// The ShowStatus event.
/// </summary>
///
/// <remarks>This event is used by the services to display the current status.</remarks>
///
public class ShowStatus : CompositePresentationEvent<StatusInfo>
{
}
/// <summary>
/// The StatusInfo is used by <see cref="ShowStatus">ShowStatus</see> event to display the current status.
/// </summary>
public class StatusInfo
{
/// <summary>
/// the current state of a process
/// </summary>
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;
}
/// <summary>
/// Gets or sets a value indicating whether this object is busy.
/// </summary>
public bool IsBusy => CurrentState == StatusState.Busy;
/// <summary>
/// Gets or sets the IsOk flag.
/// </summary>
public bool IsOk
{
get;
set;
}
/// <summary>
/// Gets or sets the progress bar percentage.
/// </summary>
public decimal Percentage
{
get;
set;
}
/// <summary>
/// Gets or sets the status information.
/// </summary>
public string Text
{
get;
set;
}
/// <summary>
/// Gets or sets the id of the process.
/// </summary>
public int ProcessId
{
get;
set;
}
/// <summary>
/// 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.
/// </summary>
/// <param name="state"></param>
/// <param name="percentage"></param>
/// <param name="processId"></param>
/// <param name="text"></param>
/// <param name="isOk"></param>
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;
}
}
}