using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CobXmlSupport
{
    public class GenSetting : ICloneable
    {
        public event SaveHandler evSave;
        public EventArgs e = null;
        public delegate void SaveHandler(GenSetting G, EventArgs e);

        public string ActualFile { get; set; }
        public bool AnaTag { get; set; }
        public string Company { get; set; }
        public bool CountVars { get; set; }
        public bool Displays { get; set; }
        public string ExpPrefix { get; set; }
        public string FilePath { get; set; }
        public string LogSectName { get; set; }
        public string LogVarName { get; set; }
        public string MaxOcc { get; set; }
        public bool MvToDisp { get; set; }
        public bool NoNsRef { get; set; }
        public bool Perform { get; set; }
        public string Prefix { get; set; }
        public bool Unique { get; set; }
        public bool UniqueAttrVars { get; set; }
        public bool UniqueVars { get; set; }
        public bool UserCodeBcup { get; set; }
        public string UserName { get; set; }
        public bool Values { get; set; }
        public bool Wrap { get; set; }
        public bool ShowTestbtns { get; set; }
        public savedFile[] fileList { get; set; }

        public void GetSettings()
        {
            this.ActualFile = S.ettingActualFile;
            this.AnaTag = S.ettingAnaTag;
            this.Company = S.ettingCompany;
            this.CountVars = S.ettingCountVars;
            this.Displays = S.ettingDisplays;
            this.ExpPrefix = S.ettingExpPrefix;
            this.FilePath = S.ettingFilePath;
            this.LogSectName = S.ettingLogSectName;
            this.LogVarName = S.ettingLogVarName;
            this.MaxOcc = S.ettingMaxOcc;
            this.MvToDisp = S.ettingMvToDisp;
            this.NoNsRef = S.ettingNoNsRef;
            this.Perform = S.ettingPerform;
            this.Prefix = S.ettingPrefix;
            this.Unique = S.ettingUnique;
            this.UniqueAttrVars = S.ettingUniqueAttrVars;
            this.UniqueVars = S.ettingUniqueVars;
            this.UserCodeBcup = S.ettingUserCodeBcup;
            this.UserName = S.ettingUserName;
            this.Values = S.ettingValues;
            this.Wrap = S.ettingWrap;
            this.ShowTestbtns = S.ettingShowTestbtns;
            this.fileList = S.ettingList==null?null:S.ettingList.ToArray();

            if (evSave != null)
            {
                evSave(this, e);
            }
        }

        public void SetSettings()
        {

            S.ettingActualFile = this.ActualFile;
            S.ettingAnaTag = this.AnaTag;
            S.ettingCompany = this.Company;
            S.ettingCountVars = this.CountVars;
            S.ettingDisplays = this.Displays;
            S.ettingExpPrefix = this.ExpPrefix;
            S.ettingFilePath = this.FilePath;
            S.ettingLogSectName = this.LogSectName;
            S.ettingLogVarName = this.LogVarName;
            S.ettingMaxOcc = this.MaxOcc;
            S.ettingMvToDisp = this.MvToDisp;
            S.ettingNoNsRef = this.NoNsRef;
            S.ettingPerform = this.Perform;
            S.ettingPrefix = this.Prefix;
            S.ettingUnique = this.Unique;
            S.ettingUniqueAttrVars = this.UniqueAttrVars;
            S.ettingUniqueVars = this.UniqueVars;
            S.ettingUserCodeBcup = this.UserCodeBcup;
            S.ettingUserName = this.UserName;
            S.ettingValues = this.Values;
            S.ettingWrap = this.Wrap;
            S.ettingShowTestbtns = this.ShowTestbtns;
            S.ettingList = null;
            if (this.fileList != null)
            {
                foreach (savedFile locSF in this.fileList)
                {
                    S.ettingListAdd(locSF);
                }
            }
            else S.ettingList = null;
        }

        public object Clone()
        {
            GenSetting tmpGenSetting = new GenSetting();
            tmpGenSetting = (GenSetting)this.MemberwiseClone();
            return tmpGenSetting;
        }

    }
}
