-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7ed6597
commit 89d51f1
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System.Numerics; | ||
using System.Text; | ||
using Lagrange.Core.Core.Packets.Message.Element; | ||
using Lagrange.Core.Core.Packets.Message.Element.Implementation; | ||
|
||
namespace Lagrange.Core.Message.Entity; | ||
|
||
[MessageElement(typeof(VideoFile))] | ||
public class VideoEntity : IMessageEntity | ||
{ | ||
public string FilePath { get; set; } = string.Empty; | ||
|
||
public Vector2 Size { get; } | ||
|
||
public int VideoSize { get; } | ||
|
||
internal VideoEntity(Vector2 size, int videoSize, string filePath) | ||
{ | ||
Size = size; | ||
VideoSize = videoSize; | ||
FilePath = filePath; | ||
} | ||
|
||
internal VideoEntity() { } | ||
|
||
IEnumerable<Elem> IMessageEntity.PackElement() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
IMessageEntity? IMessageEntity.UnpackElement(Elem elem) | ||
{ | ||
if (elem.VideoFile is not { } videoFile) return null; | ||
|
||
var size = new Vector2(videoFile.FileWidth, videoFile.FileHeight); | ||
|
||
return new VideoEntity(size, elem.VideoFile.FileSize, Encoding.UTF8.GetString(elem.VideoFile.FileName)); | ||
} | ||
|
||
public string ToPreviewString() | ||
{ | ||
return $"[Video {Size.X}x{Size.Y}]: {VideoSize}"; | ||
} | ||
} |