Files
Aaru/Aaru.Core/Sidecar/Events.cs

76 lines
3.8 KiB
C#
Raw Normal View History

2017-08-08 12:15:55 +01:00
// /***************************************************************************
2020-02-27 12:31:25 +00:00
// Aaru Data Preservation Suite
2017-08-08 12:15:55 +01:00
// ----------------------------------------------------------------------------
//
// Filename : Events.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
2017-08-08 12:15:55 +01:00
//
// Component : Core algorithms.
2017-08-08 12:15:55 +01:00
//
// --[ Description ] ----------------------------------------------------------
//
// Events to glue user interface with sidecar creation.
2017-08-08 12:15:55 +01:00
//
// --[ License ] --------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
2022-02-18 10:02:53 +00:00
// Copyright © 2011-2022 Natalia Portillo
2017-08-08 12:15:55 +01:00
// ****************************************************************************/
2022-03-06 13:29:38 +00:00
namespace Aaru.Core;
2022-03-07 07:36:44 +00:00
using Aaru.CommonTypes;
2022-03-06 13:29:38 +00:00
public sealed partial class Sidecar
2017-08-08 12:15:55 +01:00
{
2022-03-06 13:29:38 +00:00
/// <summary>Initializes a progress indicator (e.g. makes a progress bar visible)</summary>
public event InitProgressHandler InitProgressEvent;
/// <summary>Updates a progress indicator with text</summary>
public event UpdateProgressHandler UpdateProgressEvent;
/// <summary>Uninitializes a progress indicator (e.g. adds a newline to the console)</summary>
public event EndProgressHandler EndProgressEvent;
/// <summary>Initializes a secondary progress indicator (e.g. makes a progress bar visible)</summary>
public event InitProgressHandler2 InitProgressEvent2;
/// <summary>Event raised to update the values of a determinate progress bar</summary>
public event UpdateProgressHandler2 UpdateProgressEvent2;
/// <summary>Event raised when the progress bar is not longer needed</summary>
public event EndProgressHandler2 EndProgressEvent2;
/// <summary>Updates a status indicator</summary>
public event UpdateStatusHandler UpdateStatusEvent;
2017-08-08 12:15:55 +01:00
2022-03-06 13:29:38 +00:00
/// <summary>Initializes a progress indicator (e.g. makes a progress bar visible)</summary>
public void InitProgress() => InitProgressEvent?.Invoke();
2017-08-08 12:15:55 +01:00
2022-03-06 13:29:38 +00:00
/// <summary>Updates a progress indicator with text</summary>
public void UpdateProgress(string text, long current, long maximum) =>
UpdateProgressEvent?.Invoke(string.Format(text, current, maximum), current, maximum);
2017-08-08 12:15:55 +01:00
2022-03-06 13:29:38 +00:00
/// <summary>Uninitializes a progress indicator (e.g. adds a newline to the console)</summary>
public void EndProgress() => EndProgressEvent?.Invoke();
2017-08-08 12:15:55 +01:00
2022-03-06 13:29:38 +00:00
/// <summary>Initializes a secondary progress indicator (e.g. makes a progress bar visible)</summary>
public void InitProgress2() => InitProgressEvent2?.Invoke();
2017-08-08 12:15:55 +01:00
2022-03-06 13:29:38 +00:00
/// <summary>Event raised to update the values of a determinate progress bar</summary>
public void UpdateProgress2(string text, long current, long maximum) =>
UpdateProgressEvent2?.Invoke(string.Format(text, current, maximum), current, maximum);
2017-08-08 12:15:55 +01:00
2022-03-06 13:29:38 +00:00
/// <summary>Event raised when the progress bar is not longer needed</summary>
public void EndProgress2() => EndProgressEvent2?.Invoke();
2017-08-08 12:15:55 +01:00
2022-03-06 13:29:38 +00:00
/// <summary>Updates a status indicator</summary>
2022-03-07 07:36:44 +00:00
public void UpdateStatus(string text, params object[] args) => UpdateStatusEvent?.Invoke(string.Format(text, args));
2017-12-19 20:33:03 +00:00
}