using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using DDUtilityApp.LOGPARSER.DATA;
using DDUtilityApp.LOGPARSER.PARSER;
using DDUtilityApp.SECS;
using JWH;
using JWH.CONTROL;
using Telerik.WinControls.UI;

namespace DDUtilityApp.LOGPARSER
{

    public partial class FrmLogParser02 : Form
    {

        #region [ Properties ] ------------------------------------------------

        private bool RadGridControlKey { get; set; } = false;

        private StandardCollection Collection { get; set; } = new StandardCollection();

        private LogParser Parser { get; set; } = new AgvParser();

        private EisEquipment Equipment { get; set; } = null;

        private SECSDefine SECSDefine { get; set; } = null;

        private FrmFindDialog FindDialog { get; set; } = null;

        private string WindowText { get; set; } = $"[EverOne] MIS Log Viewer";

        public static string BasePath { get; set; }

        public static string DownloadPath { get; set; }

        public static string WorkflowPath { get; set; }

        #endregion

        #region [ FrmLogParser02 ] --------------------------------------------

        public FrmLogParser02()
        {
            InitializeComponent();
            this.SetLayout();
            this.SetEventHandler();

            XLogger.Instance.Control = this.tboxException;
        }

        private void SetLayout()
        {
            this.AllowDrop = true;
            this.Text = $"{this.WindowText} - Ver. {Application.ProductVersion}";
            BasePath = $"{Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)}\\DDUtility\\";
            DownloadPath = $"{BasePath}Download";
            WorkflowPath = $"{BasePath}WorkFlow";

            this.tboxLog.AllowDrop = true;
            this.tboxLog.WordWrap = false;
            this.tboxLog.Multiline = true;
            this.tboxLog.HideSelection = false;
            this.tboxLog.ScrollBars = ScrollBars.Both;
            this.tboxLog.Font = new Font("돋움체", 9);

            this.tboxException.WordWrap = false;
            this.tboxException.Font = new Font("돋움체", 9);

            this.lviewFiles.View = View.Details;
            ColumnHeader header = this.lviewFiles.Columns.Add("File Name");
            this.lviewFiles.CheckBoxes = true;
            this.lviewFiles.MultiSelect = false;
            this.lviewFiles.Sorting = System.Windows.Forms.SortOrder.Ascending;
            this.lviewFiles.ListViewItemSorter = new ListViewItemComparer(0, this.lviewFiles.Sorting);

            this.RadGrid_Setting();

            this.btnEqpSelector.Enabled = false;
            this.btnSecsDefine.Enabled = false;
            this.btnOpenWorkFlow.Enabled = false;

            this.ActiveControl = this.btnParsing;
        }

        private void SetEventHandler()
        {
            // DragDrop
            this.DragDrop += Control_DragDrop;
            this.DragEnter += Control_DragEnter;

            this.tboxLog.DragDrop += Control_DragDrop;
            this.tboxLog.DragEnter += Control_DragEnter;
            this.tboxLog.KeyDown += TboxLog_KeyDown;

            // File List
            this.lviewFiles.Click += LviewFiles_Click;
            this.lviewFiles.ColumnClick += LviewFiles_ColumnClick;
            this.lviewFiles.Resize += LviewFiles_Resize;
            this.tboxFilename.KeyDown += TboxFilename_KeyDown;
            this.btnFileAdd.Click += BtnFileAdd_Click;
            this.btnFileRemove.Click += BtnFileRemove_Click;
            this.btnFileClear.Click += BtnFileClear_Click;
            this.btnParsing.Click += BtnParsing_Click;
            this.btnEqpSelector.Click += BtnEqpSelector_Click;

            // Option
            this.btnClearFilter.Click += BtnClearFilter_Click;
            this.btnColumnResize.Click += BtnColumnResize_Click;
            this.btnOpenOriginal.Click += BtnOpenOriginal_Click;
            this.btnSecsDefine.Click += BtnSecsDefine_Click;
            this.btnOpenWorkFlow.Click += BtnOpenWorkFlow_Click;

            // StatusBar
            this.btnGoLineNumber.Click += BtnGoLineNumber_Click;
            this.tboxLineNumber.KeyDown += TboxLineNumber_KeyDown;

            // Grid
            this.grid.DataBindingComplete += RadGrid_DataBindingComplete;
            this.grid.SelectionChanged += RadGrid_SelectionChanged;
            this.grid.ViewCellFormatting += RadGrid_ViewCellFormatting;
            this.grid.CellDoubleClick += RadGrid_CellDoubleClick;
            this.grid.KeyDown += RadGrid_KeyDown;
            this.grid.KeyUp += RadGrid_KeyUp;
            this.grid.CellClick += RadGrid_CellClick;
        }

        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            switch (keyData)
            {
                case Keys.F3:
                    if (this.FindDialog != null) this.FindDialog.Next();
                    break;
                case Keys.F5:
                    this.BtnParsing_Click(this.btnParsing, new EventArgs());
                    break;
                case Keys.F6:
                    this.BtnColumnResize_Click(this.btnColumnResize, new EventArgs());
                    break;
            }

            return base.ProcessCmdKey(ref msg, keyData);
        }

        #endregion


        #region [ Control Event ] ---------------------------------------------

        private void Control_DragDrop(object sender, DragEventArgs e)
        {
            XLogger.Instance.Info(e);
            if (this.chkAutoClear.Checked) this.lviewFiles.Items.Clear();

            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
            foreach (string filePath in files)
            {
                ListViewItem lviewItem = this.lviewFiles.Items.Add(Path.GetFileName(filePath));
                lviewItem.Checked = true;
                lviewItem.Tag = filePath;
            }

            this.BtnParsing_Click(this.btnParsing, new EventArgs());
        }

        private void Control_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy;
        }


        private void TboxLog_KeyDown(object sender, KeyEventArgs e)
        {
            if ((e.KeyData & Keys.Control) == Keys.Control && (e.KeyData & Keys.F) == Keys.F)
            {
                if (this.FindDialog == null)
                {
                    this.FindDialog = new FrmFindDialog(this.tboxLog);
                    this.FindDialog.StartPosition = FormStartPosition.Manual;
                    this.FindDialog.Location = this.grid.PointToScreen(new Point(10, 10));
                    this.FindDialog.FormClosed += (object sender1, FormClosedEventArgs e1) => { this.FindDialog = null; };
                    this.FindDialog.FInd += (object sender1, EventArgs e1) => { };
                    this.FindDialog.Show();
                }
                else
                {
                    this.FindDialog.Activate();
                }

                this.FindDialog.SelectedText = this.tboxLog.SelectedText;
            }
        }

        private void LviewFiles_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.lviewFiles.Items.Count < 1) return;
                if (this.lviewFiles.SelectedItems.Count < 1) return;

                int index = -1;
                index = this.lviewFiles.SelectedItems[0].Index;

                this.tboxFilename.Text = this.lviewFiles.Items[index].Tag as string;
                if (string.IsNullOrEmpty(this.tboxFilename.Text) == false && this.tboxFilename.Text.Length > 6)
                {
                    this.tboxFilename.SelectionStart = this.tboxFilename.Text.Length - 6;
                    this.tboxFilename.SelectionLength = 2;
                    this.tboxFilename.Focus();
                }
            }
            catch (Exception ex)
            {
                XLogger.Instance.Fatal(ex);
            }
        }

        private void LviewFiles_ColumnClick(object sender, ColumnClickEventArgs e)
        {
            try
            {
                System.Windows.Forms.SortOrder sorting = System.Windows.Forms.SortOrder.None;
                switch (this.lviewFiles.Sorting)
                {
                    case System.Windows.Forms.SortOrder.None:
                        sorting = System.Windows.Forms.SortOrder.Ascending;
                        break;
                    case System.Windows.Forms.SortOrder.Ascending:
                        sorting = System.Windows.Forms.SortOrder.Descending;
                        break;
                    case System.Windows.Forms.SortOrder.Descending:
                        sorting = System.Windows.Forms.SortOrder.None;
                        break;
                }

                this.lviewFiles.Sorting = sorting;
                this.lviewFiles.ListViewItemSorter = new ListViewItemComparer(e.Column, this.lviewFiles.Sorting);
            }
            catch (Exception ex)
            {
                XLogger.Instance.Fatal(ex);
            }
        }

        private void LviewFiles_Resize(object sender, EventArgs e)
        {
            int width = this.lviewFiles.Width - 32;
            int headerWidth = width / this.lviewFiles.Columns.Count;
            foreach (ColumnHeader header in this.lviewFiles.Columns)
                header.Width = headerWidth;
        }

        private void TboxFilename_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Enter)
                this.BtnFileAdd_Click(this.btnFileAdd, new EventArgs());
        }

        private void BtnFileAdd_Click(object sender, EventArgs e)
        {
            try
            {
                ListViewItem lviewItem = this.lviewFiles.Items.Add(Path.GetFileName(this.tboxFilename.Text));
                lviewItem.Checked = true;
                lviewItem.Tag = this.tboxFilename.Text;
            }
            catch (Exception ex)
            {
                XLogger.Instance.Fatal(ex);
            }
        }

        private void BtnFileRemove_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.lviewFiles.SelectedItems.Count <= 0) return;

                this.lviewFiles.SelectedItems[0].Remove();
                this.tboxFilename.Text = string.Empty;
            }
            catch (Exception ex)
            {
                XLogger.Instance.Fatal(ex);
            }
        }

        private void BtnFileClear_Click(object sender, EventArgs e)
        {
            this.Text = $"{this.WindowText} - Ver. {Application.ProductVersion}";

            this.lviewFiles.Items.Clear();
            this.tboxLog.Clear();
            this.tboxException.Clear();

            this.grid.DataSource = null;
        }

        private void BtnParsing_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                this.Parsing();

                if (this.chkFilterLinktest.Checked)
                    this.grid.AutoBinding(this.Collection.Where(item => item.Column1 != "LINKTEST").ToArray());
                else
                    this.grid.AutoBinding(this.Collection.ToArray());
            }
            catch (Exception ex)
            {
                XLogger.Instance.Fatal(ex);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }

        private void BtnEqpSelector_Click(object sender, EventArgs e)
        {
            try
            {
            }
            catch (Exception ex)
            {
                XLogger.Instance.Fatal(ex, true);
            }
        }


        private void BtnClearFilter_Click(object sender, EventArgs e)
        {
            this.grid.MasterTemplate.FilterDescriptors.Clear();
        }

        private void BtnColumnResize_Click(object sender, EventArgs e)
        {
            this.grid.BestFitColumns(BestFitColumnMode.DisplayedCells);
        }

        private void BtnOpenOriginal_Click(object sender, EventArgs e)
        {
            try
            {
                List<string> lstFileName = new List<string>();

                // Process Unit: File
                foreach (ListViewItem lviewItem in this.lviewFiles.Items)
                {
                    if (lviewItem.Checked == false) continue;
                    XLogger.Instance.Info(lviewItem.Text);

                    string sourceFileName = lviewItem.Tag as string;
                    string destPath = DownloadPath;
                    if (System.IO.Directory.Exists(destPath) == false) System.IO.Directory.CreateDirectory(destPath);

                    string destFileName = $@"{destPath}\{System.IO.Path.GetFileName(sourceFileName)}";
                    if (this.chkDownload.Checked == false) System.IO.File.Copy(sourceFileName, destFileName, true);
                    sourceFileName = destFileName;

                    lstFileName.Add(sourceFileName);
                }   // Process Unit: File

                foreach (string filename in lstFileName)
                    Process.Start(filename);
            }
            catch (Exception ex)
            {
                XLogger.Instance.Fatal(ex);
            }
        }

        private void BtnSecsDefine_Click(object sender, EventArgs e)
        {
            FrmSecsDefine frm = new FrmSecsDefine(this.Parser.SECSDefine);
            frm.StartPosition = FormStartPosition.Manual;
            int x = this.Location.X + this.Width - frm.Width - 32;
            int y = this.Location.Y + 32;
            frm.Location = new Point(x, y);
            frm.Text = this.tboxEqModelID.Text;
            frm.Show(this);
        }

        private void BtnOpenWorkFlow_Click(object sender, EventArgs e)
        {
            try
            {
                FrmWorkFlow dlg = new FrmWorkFlow();
                //dlg.Owner = this;
                dlg.Size = this.Size;
                dlg.Location = this.Location;
                dlg.StartPosition = FormStartPosition.Manual;
                //dlg.StartPosition = FormStartPosition.CenterParent;
                dlg.Text = this.tboxEqModelID.Text;
                dlg.Show();
            }
            catch (Exception ex)
            {
                XLogger.Instance.Fatal(ex);
            }
        }

        private void TboxLineNumber_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Enter)
                this.BtnGoLineNumber_Click(this.btnGoLineNumber, new EventArgs());
        }

        private void BtnGoLineNumber_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            try
            {
                int lineNumber = -1;
                int.TryParse(this.tboxLineNumber.Text, out lineNumber);
                foreach (GridViewRowInfo row in this.grid.Rows)
                {
                    try
                    {
                        StandardData standardData = row.DataBoundItem as StandardData;
                        if (standardData == null) continue;
                        if (lineNumber <= standardData.LineNumber)
                        {
                            row.IsSelected = true;
                            row.IsCurrent = true;
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        XLogger.Instance.Debug(ex);
                    }
                }
            }
            catch (Exception ex)
            {
                XLogger.Instance.Fatal(ex);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }

        #endregion

        #region [ Grid ] ------------------------------------------------------

        private void RadGrid_Setting()
        {
            this.grid.MultiSelect = true;
            this.grid.Columns.Clear();
            //this.grid.AddColumn("LineNumber");
            this.grid.AddColumn("DateTime");
            this.grid.AddColumn("Level");
            this.grid.AddColumn("Server");
            this.grid.AddColumn("Service");
            this.grid.AddColumn("Type");
            this.grid.AddColumn("MessageName");
            this.grid.AddColumn("Return");
            this.grid.AddColumn("Value");
            this.grid.AddColumn("EquipmentID");
            this.grid.AddColumn("PortID", "VEHICLEID");
            this.grid.AddColumn("CarrierID");
            this.grid.AddColumn("LotID");
            this.grid.AddColumn("HostPanelID", "SourcePort");
            this.grid.AddColumn("PanelID", "DestPort");
            this.grid.AddColumn("PanelQty");
            this.grid.AddColumn("TID");
            this.grid.AddColumn("SystemByte");
            this.grid.AddColumn("Column1", "CommandID");
            this.grid.AddColumn("Column2", "WayPoint");
            this.grid.AddColumn("Column3");
            this.grid.AddColumn("Column4");
            this.grid.AddColumn("Column5");
        }

        private void RadGrid_KeyUp(object sender, KeyEventArgs e)
        {
            this.RadGridControlKey = e.Control;
        }

        private void RadGrid_KeyDown(object sender, KeyEventArgs e)
        {
            this.RadGridControlKey = e.Control;
        }

        private void RadGrid_CellClick(object sender, GridViewCellEventArgs e)
        {
            try
            {
                RadGridView rgrid = sender as RadGridView;
                if (rgrid == null) rgrid = this.grid;
                if (this.RadGridControlKey == false) return;

                foreach (GridViewDataColumn column in rgrid.Columns)
                {
                    foreach (BaseFormattingObject obj in column.ConditionalFormattingObjectList)
                    {
                        if (new string[] { "Marking" }.Contains(obj.Name))
                        {
                            ExpressionFormattingObject formatting = obj as ExpressionFormattingObject;
                            formatting.Expression += $" AND {e.Column.Name} = '{e.Value}'";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                XLogger.Instance.Fatal(ex);
            }
        }

        private void RadGrid_CellDoubleClick(object sender, GridViewCellEventArgs e)
        {
            try
            {
                RadGridView rgrid = sender as RadGridView;
                if (rgrid == null) rgrid = this.grid;

                // RowHeader.DoubleClick
                if (e.ColumnIndex == -1)
                {
                    StandardData standardData = e.Row.DataBoundItem as StandardData;
                    if (standardData != null)
                    {
                        this.tboxLineNumber.Text = standardData.LineNumber.ToString();
                        this.tboxLineNumber.Tag = e.Row;
                    }
                    return;
                }

                List<BaseFormattingObject> lstFormat = new List<BaseFormattingObject>();
                foreach (GridViewDataColumn column in rgrid.Columns)
                {
                    lstFormat.Clear();
                    foreach (BaseFormattingObject obj in column.ConditionalFormattingObjectList)
                    {
                        if (new string[] { "Level_Error", "Type_Error", "Server_Error", "Return_1" }.Contains(obj.Name)) continue;
                        lstFormat.Add(obj);
                    }

                    foreach (BaseFormattingObject obj in lstFormat)
                        column.ConditionalFormattingObjectList.Remove(obj);
                }

                var value = e.Value;
                //DateTime column Convert
                if (e.Value.GetType() == typeof(DateTime))
                {
                    var tempData = (DateTime)e.Value;
                    value = tempData.ToString("yyyy-MM-dd HH:mm:ss.fff");
                }

                ExpressionFormattingObject formatting = new ExpressionFormattingObject($"Marking", $"{e.Column.Name} = '{value}'", true);
                formatting.RowBackColor = Color.FromArgb(128, 0, 255, 0);
                rgrid.Columns[e.Column.Name].ConditionalFormattingObjectList.Add(formatting);
            }
            catch (Exception ex)
            {
                XLogger.Instance.Fatal(ex);
            }
        }

        private void RadGrid_ViewCellFormatting(object sender, CellFormattingEventArgs e)
        {
            if (e.CellElement is GridRowHeaderCellElement && e.Row is GridViewDataRowInfo)
            {
#if ROW_INDEX
                GridDataView dataView = this.grid.MasterTemplate.DataView as GridDataView;
                e.CellElement.Text = (dataView.Indexer.Items.IndexOf(e.Row) + 1).ToString();
#else
                StandardData standardData = e.Row.DataBoundItem as StandardData;
                e.CellElement.Text = (standardData != null ? standardData.LineNumber.ToString() : "");
#endif
                //e.CellElement.TextImageRelation = TextImageRelation.ImageBeforeText;
            }
            else
            {
                e.CellElement.ResetValue(LightVisualElement.TextImageRelationProperty, Telerik.WinControls.ValueResetFlags.Local);
            }
        }

        private void RadGrid_DataBindingComplete(object sender, GridViewBindingCompleteEventArgs e)
        {
            RadGridView rgrid = sender as RadGridView;
            if (rgrid == null) return;

            if (rgrid.Columns.Contains("LineNumber")) rgrid.Columns["LineNumber"].IsVisible = false;
            if (rgrid.Columns.Contains("DateTime")) rgrid.Columns["DateTime"].FormatString = "{0:yyyy-MM-dd HH:mm:ss.fff}";
            if (rgrid.Columns.Contains("Body")) rgrid.Columns["Body"].IsVisible = false;

            if (rgrid.Columns.Contains("Level"))
            {
                rgrid.Columns["Level"].TextAlignment = ContentAlignment.MiddleCenter;
                ExpressionFormattingObject formatting = new ExpressionFormattingObject($"Level_Error", "Level='ERROR'", true);
                formatting.RowBackColor = Color.FromArgb(128, 255, 0, 0);
                rgrid.Columns["Level"].ConditionalFormattingObjectList.Add(formatting);
            }

            if (rgrid.Columns.Contains("Type"))
            {
                ExpressionFormattingObject formatting = new ExpressionFormattingObject($"Type_Error", "Server<>'TID' and Type='ERROR'", true);
                formatting.RowBackColor = Color.FromArgb(128, 255, 0, 0);
                rgrid.Columns["Type"].ConditionalFormattingObjectList.Add(formatting);
            }

            if (rgrid.Columns.Contains("Return"))
            {
                rgrid.Columns["Return"].TextAlignment = ContentAlignment.MiddleCenter;
                ExpressionFormattingObject formatting = new ExpressionFormattingObject($"Return_1", "Return<>0", true);
                formatting.RowBackColor = Color.FromArgb(128, 255, 0, 0);
                rgrid.Columns["Return"].ConditionalFormattingObjectList.Add(formatting);
            }

            rgrid.BestFitColumns(BestFitColumnMode.DisplayedCells);
        }

        private void RadGrid_SelectionChanged(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                RadGridView rgrid = sender as RadGridView;
                if (rgrid == null) return;
                if (rgrid.SelectedRows.Count < 1) return;

                StandardData data = rgrid.SelectedRows.FirstOrDefault().DataBoundItem as StandardData;
                if (data == null) return;

                int dataLineNumber = data.LineNumber - 1;
                int startLineNumber = dataLineNumber - 10;
                int bottomLineNumber = dataLineNumber + 100;
                int dataIndex = this.tboxLog.Text.IndexOf($"{data.LineNumber.ToString("000000")}:");
                int difference = dataIndex - this.tboxLog.GetFirstCharIndexFromLine(dataLineNumber);

                this.tboxLog.SuspendLayout();
                if (bottomLineNumber >= this.tboxLog.Lines.Length) bottomLineNumber = this.tboxLog.Lines.Length - 1;
                this.tboxLog.SelectionStart = this.tboxLog.GetFirstCharIndexFromLine(bottomLineNumber) + difference;
                this.tboxLog.ScrollToCaret();

                if (startLineNumber < 0) startLineNumber = 0;
                this.tboxLog.SelectionStart = this.tboxLog.GetFirstCharIndexFromLine(startLineNumber) + difference;
                this.tboxLog.ScrollToCaret();

                this.tboxLog.SelectionStart = this.tboxLog.GetFirstCharIndexFromLine(dataLineNumber) + difference;
                this.tboxLog.SelectionLength = 6;
                this.tboxLog.ScrollToCaret();
            }
            catch (Exception ex)
            {
                XLogger.Instance.Fatal(ex);
            }
            finally
            {
                this.tboxLog.ResumeLayout();
                this.Cursor = Cursors.Default;
            }
        }

        #endregion

        #region [ Method ] ----------------------------------------------------

        private StandardCollection Parsing()
        {
            try
            {
                this.tboxLog.Clear();
                this.Collection.Clear();

                List<string> lstFileName = new List<string>();
                string strTitle = string.Empty;

                // Process Unit: File
                foreach (ListViewItem lviewItem in this.lviewFiles.Items)
                {
                    if (lviewItem.Checked == false) continue;
                    XLogger.Instance.Info(lviewItem.Text);

                    string sourceFileName = lviewItem.Tag as string;
                    if (this.chkDownload.Checked)
                    {
                        string destPath = DownloadPath;
                        if (System.IO.Directory.Exists(destPath) == false) System.IO.Directory.CreateDirectory(destPath);

                        if (string.IsNullOrEmpty(strTitle)) strTitle = System.IO.Path.GetFileNameWithoutExtension(sourceFileName);
                        string destFileName = $@"{destPath}\{System.IO.Path.GetFileName(sourceFileName)}";
                        System.IO.File.Copy(sourceFileName, destFileName, true);
                        sourceFileName = destFileName;
                    }

                    lstFileName.Add(sourceFileName);
                }   // Process Unit: File

                this.Parser.ModelID = this.tboxEqModelID.Text;
                this.Parser.SECSDefine = this.SECSDefine;
                this.Parser.Parsing(lstFileName.ToArray());
                this.Text = $"{strTitle} - Ver. {Application.ProductVersion}";
                this.tboxLog.Text = this.Parser.LogString.ToString();
                this.Collection.AddRange(this.Parser.StandardCollection);

                return this.Collection;
            }
            catch (Exception ex)
            {
                XLogger.Instance.Fatal(ex);
                return this.Collection;
            }
        }

        #endregion

    }

}
