178 lines
4.3 KiB
C#
178 lines
4.3 KiB
C#
namespace MarketAlly.Replicate.Maui;
|
|
|
|
/// <summary>
|
|
/// Event args for when a transformation starts.
|
|
/// </summary>
|
|
public class TransformationStartedEventArgs : EventArgs
|
|
{
|
|
/// <summary>
|
|
/// The type of transformation being started.
|
|
/// </summary>
|
|
public TransformationType Type { get; }
|
|
|
|
public TransformationStartedEventArgs(TransformationType type) => Type = type;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event args for when a transformation completes successfully.
|
|
/// </summary>
|
|
public class TransformationCompletedEventArgs : EventArgs
|
|
{
|
|
/// <summary>
|
|
/// The type of transformation that completed.
|
|
/// </summary>
|
|
public TransformationType Type { get; }
|
|
|
|
/// <summary>
|
|
/// The URL of the result output.
|
|
/// </summary>
|
|
public string? ResultUrl { get; }
|
|
|
|
/// <summary>
|
|
/// The full prediction result.
|
|
/// </summary>
|
|
public PredictionResult Result { get; }
|
|
|
|
public TransformationCompletedEventArgs(TransformationType type, PredictionResult result)
|
|
{
|
|
Type = type;
|
|
Result = result;
|
|
ResultUrl = result.Output;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event args for when a transformation fails.
|
|
/// </summary>
|
|
public class TransformationErrorEventArgs : EventArgs
|
|
{
|
|
/// <summary>
|
|
/// The type of transformation that failed.
|
|
/// </summary>
|
|
public TransformationType Type { get; }
|
|
|
|
/// <summary>
|
|
/// The exception that occurred.
|
|
/// </summary>
|
|
public Exception Error { get; }
|
|
|
|
public TransformationErrorEventArgs(TransformationType type, Exception error)
|
|
{
|
|
Type = type;
|
|
Error = error;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event args for when an image is selected.
|
|
/// </summary>
|
|
public class ImageSelectedEventArgs : EventArgs
|
|
{
|
|
/// <summary>
|
|
/// The selected image bytes.
|
|
/// </summary>
|
|
public byte[] ImageBytes { get; }
|
|
|
|
public ImageSelectedEventArgs(byte[] imageBytes) => ImageBytes = imageBytes;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event args for when an image is tapped.
|
|
/// </summary>
|
|
public class ImageTappedEventArgs : EventArgs
|
|
{
|
|
/// <summary>
|
|
/// Whether this is the source image (true) or result image (false).
|
|
/// </summary>
|
|
public bool IsSourceImage { get; }
|
|
|
|
/// <summary>
|
|
/// The URL of the result, if applicable.
|
|
/// </summary>
|
|
public string? ResultUrl { get; }
|
|
|
|
/// <summary>
|
|
/// The image bytes, if available.
|
|
/// </summary>
|
|
public byte[]? ImageBytes { get; }
|
|
|
|
public ImageTappedEventArgs(bool isSourceImage, string? resultUrl = null, byte[]? imageBytes = null)
|
|
{
|
|
IsSourceImage = isSourceImage;
|
|
ResultUrl = resultUrl;
|
|
ImageBytes = imageBytes;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event args for when a file is saved successfully.
|
|
/// </summary>
|
|
public class FileSavedEventArgs : EventArgs
|
|
{
|
|
/// <summary>
|
|
/// The full path to the saved file.
|
|
/// </summary>
|
|
public string FilePath { get; }
|
|
|
|
/// <summary>
|
|
/// The type of file saved (Image or Video).
|
|
/// </summary>
|
|
public TransformationType Type { get; }
|
|
|
|
/// <summary>
|
|
/// The size of the saved file in bytes.
|
|
/// </summary>
|
|
public long FileSizeBytes { get; }
|
|
|
|
public FileSavedEventArgs(string filePath, TransformationType type, long fileSizeBytes)
|
|
{
|
|
FilePath = filePath;
|
|
Type = type;
|
|
FileSizeBytes = fileSizeBytes;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event args for when a file save fails.
|
|
/// </summary>
|
|
public class FileSaveErrorEventArgs : EventArgs
|
|
{
|
|
/// <summary>
|
|
/// The type of file that failed to save.
|
|
/// </summary>
|
|
public TransformationType Type { get; }
|
|
|
|
/// <summary>
|
|
/// The exception that occurred.
|
|
/// </summary>
|
|
public Exception Error { get; }
|
|
|
|
public FileSaveErrorEventArgs(TransformationType type, Exception error)
|
|
{
|
|
Type = type;
|
|
Error = error;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event args for when the transformer state changes.
|
|
/// </summary>
|
|
public class StateChangedEventArgs : EventArgs
|
|
{
|
|
/// <summary>
|
|
/// The previous state of the control.
|
|
/// </summary>
|
|
public TransformerState PreviousState { get; }
|
|
|
|
/// <summary>
|
|
/// The new/current state of the control.
|
|
/// </summary>
|
|
public TransformerState NewState { get; }
|
|
|
|
public StateChangedEventArgs(TransformerState previousState, TransformerState newState)
|
|
{
|
|
PreviousState = previousState;
|
|
NewState = newState;
|
|
}
|
|
}
|