using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using EHF;

namespace Valg.EVA.Skanning.Scan.ReadSoftEmulation
{
    internal class Form : DynamicObject, IEHF_IForm
    {
        private readonly Fields _fields = new Fields();
        private string _name;

        public void Delete()
        {
            
        }

        public void DeleteField(short FieldNo)
        {
            throw new NotImplementedException();
        }

        public bool ExistFieldByName(string FieldName, short Index, out IEHF_IField FieldObj)
        {
            throw new NotImplementedException();
        }

        public bool ExistFieldByNo(short FieldNo, out IEHF_IField FieldObj)
        {
            throw new NotImplementedException();
        }

        public IEHF_IField GetFieldByName(string FieldName, short Index)
        {
            throw new NotImplementedException();
        }

        public IEHF_IField GetFieldByNo(short FieldNo)
        {
            throw new NotImplementedException();
        }

        public object GetClassicObject()
        {
            dynamic ret = new ExpandoObject();
            ret.FrontRotatedDegrees = FrontRotatedDegrees;
            ret.BackRotatedDegrees = BackRotatedDegrees;
            ret.Bytes = new[] { ArchiveFrontImageBytes, ArchiveBackImageBytes };
            ret.ScannedOrder = ScannedOrder;
            return ret;
        }

        public string ArchiveFrontImageFileName { get; set; }
        public string ArchiveBackImageFileName { get; set; }
        public int BatchIndexOldImpl { get; }
        public int BatchNoOldImpl { get; }
        public string ComplementString { get; set; }
        public string ComplementMessage { get; set; }
        public bool DualSided { get; }
        public string InfoString { get; set; }
        public string Name { get { return _name; } }
        public ehQueue Queue { get; set; }
        public string SourceFrontImageFileName { get; set; }
        public string SourceBackImageFileName { get; set; }
        public ehFormStatus Status { get; set; }
        public string TemporaryStorageString1 { get; set; }
        public string TemporaryStorageString2 { get; set; }
        public IEHF_IFieldCollection Fields => _fields;
        public bool FormoutDone { get; }
        public string BatchDateOldImpl { get; }
        public string BatchTimeOldImpl { get; }
        public string AppendixFileNames { get; }
        public int BatchIndex { get; set; }
        public int BatchNo { get; set; }
        public string BatchDate { get; set; }
        public string BatchTime { get; set; }
        public string BatchPrefix { get; set; }

        internal void SetName(string name)
        {
            _name = name;
        }
        internal void AddField(string name, EHF.ehFieldType type, string value)
        {
            var field = new Field()
            {
                Name = name,
                Type = type,
                FieldNo = Convert.ToInt16(_fields.Count),
                Value = value
            };

            _fields.Add(field);
        }
        internal void AddField(EHF.Field field)
        {
            _fields.Add(field);
        }

        public byte[] ArchiveFrontImageBytes { get; set; }
        public byte[] ArchiveBackImageBytes { get; set; }
        public int FrontRotatedDegrees { get; set; }
        public int BackRotatedDegrees { get; set; }
        public int ScannedOrder { get; set; }

    }
}

